Skip to content
Advertisement

Tag: function

is it possible to combine these two functions into one?

I have two functions that are basically identical. The first function gets passed a mouse event where event.target is the input type=’checkbox’ the second function gets passed the input type=’checkbox’ is there a way to rewrite these into one function? Answer The only part of these two functions that differ are how you get the reference to the checkbox. So

function.name returns empty string if the function is added to an object by property

Consider this code example: Why is there a difference between the name properties of these two functions? Answer The technical explanation: NamedEvaluation The specification tells you: 13.2.5.5 Runtime Semantics: PropertyDefinitionEvaluation PropertyDefinition : PropertyName : AssignmentExpression Let propKey be the result of evaluating PropertyName. […] If IsAnonymousFunctionDefinition(AssignmentExpression) is true, then Let propValue be ? NamedEvaluation of AssignmentExpression with argument propKey. Else,

Advertisement