Questions tagged [function-expression]

100 questions
0
votes
2 answers

How is this working !function(){console.log("hi")}()

I read this on the javascript garden site. Can someone explain how it works? !function(){console.log("hi")}()
user566245
  • 4,011
  • 1
  • 30
  • 36
0
votes
2 answers

Determine if JavaScript code is an expression

I'm using the following function named isExpression to determine whether some JavaScript code is an expression: function isExpression(code) { try { new Function("return " + code); return true; } catch (e) { return…
Aadit M Shah
  • 72,912
  • 30
  • 168
  • 299
-1
votes
2 answers

How to write Java Script arrow functions in regular function syntax?

I need help to rewrite some arrow functions to regular functions but right now my brain is totally stucked, I have some example code here from a rock paper scissors game I got from kyle, how would it look if I was to ditch the arrow function please…
-1
votes
1 answer

How can I validate email,firstname and lastname?

I try to validate firstname,lastname and email taken by user and return true if its valid or return false if it is not valid then ask the user to enter again as long as it is not valid.By writing a function in Javascript. For names just…
-1
votes
1 answer

How to create a function expression that returns an array?

(The challenge reads like this) Create a function expression named getNumberAr with no parameters The getNumberAr function should return an array of 5 numbers Call getNumberAr and store its result into a variable called numbers So far I have created…
johnny
  • 3
  • 4
-1
votes
3 answers

javascript by reference and memory

guys i am trying to learn some javascript and i have a question that i think is important to ask. so what i have gotten so far is that when i do something like this: var a=function(){} during the creation phase there will be created in memory a…
-1
votes
1 answer

AngularJS - semicolon after $scope function expression?

With JavaScript, it's best practice to use semicolons after a function expression block: var myfunction = function() { alert('hello world'); }; What about in AngularJS, say in a controller, using the dreaded $scope? Often times I see these…
-1
votes
1 answer

Override function expression event listener not working

I'm trying to override the function attached to the event listener but when the event is triggered the old one is still called. var element; var newHandler = () => { if((element = this.getElementsByClassName('someClass')[0]) != null){ …
-1
votes
1 answer

Are all functions inside of an IIFE expressions?

If (function foo(){}) is an expression due to the 'context' as "(Parenthesis)" are a grouping operator and grouping operator can only contain an expression. Which leads to the question, can you declare a function inside of an IIFE or it would still…
-2
votes
1 answer

Why I can't call the initial function when I assign the initial function(a function declaration) to a variable?

I'm learning javaScript through the book" Professional JavaScript for Web developers 3rd Edition". And In section 7.1 of Chapter 7, the author puts an example to realize the decoupling between executing function and the function name: var…
chenxy
  • 1
  • 1
1 2 3 4 5 6
7