Intent of My Blog
Today, i heard the third lecture on javascript functions by Douglas Crockford. This blog is third in this series. Please refer to first and second post regarding the history and statements in javascript.
Functions in JavaScript
Today i have seen the third lecture of the series.Checkout this lecture
Key points from the presentation are:-
- function are first class object
- function can be passed, returned and shared just like any other value.
- function inherit object and store name value pair.
- function are container like objects
- functions are equivalent to Lambda
- Lambda has enormous expressive power
- Unlike most power constructs, lambda is secure
- function statement var foo = function foo(){// statements to execute}
- In JavaScript, one function can contain other functions.
- An inner function has access to the variable and parameter of function that it is contained within.
- This is called static scoping or lexical scoping
- JavaScript also supports Closure
- The scope that an inner function enjoys continues even after the parent function has returned.This is called Closure
- Closure are one of the most powerful features of JavaScript
- JavaScript is the first lambda language to go mainstream
- when a function is called with too many arguments, the extra arguments are ignored
- When the function is called with too less arguments, the missing values are set to undefined
- Methods can be invoked in four ways
- Function Form –> functionObject(argument)
- Method Form –> thisObject.methodName(arguments) and thisObject[“methodname”](arguments)
- Constructor Form –> new Function(“x”,”y”,”return x*y”)
- Apply form –> functionObject.apply(thisObject, arguments)
- When a function is invoked, it also gets a special parameter called arguments.
- arguments contain all of the arguments from the invocation
- It is an array like object (it is not a full array)
- arguments.length gives the number of arguments passed.
- In JavaScript, you can extend the built-in types(like String, Boolean)
- Do not use eval function
- Built in wrapper types like String, Boolean, Integer are not useful
- Global variables are evil
- Implied global are evils too.
- Always use functional scope.
These were some of the points from the talk.
One thought on “Learning JavaScript Programming Language Functions Part 3”