RcBuilder@walla.com
call centre: 054-5614020

self-invoking functions

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

self-invoking functions declare & execute a function at the same time example: we created an anonymous function and invoked it within the declaration, the function creates a counter variable and return a reference to another function that increase this counter. the return function can access to the counter variable (as any function behaves - any function can access all of.

Read more

javascript closure

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript closure the ability to create a private 'scope' for a function or an object! a closure is a persistent scope which holds on to local variables even after the code execution has moved out of that block tip: in javaScript, all functions have access to the scope "above" them. example: // note! plus = function(){ return ++counter; } var plus.

Read more

javascript arguments

Posted by: RcBuilder  /   Category: Array / class / function / JAVASCRIPT / Object   /   No Comments
26
Jan
2016

javascript arguments The arguments object is an Array-like object, it's a local variable available within all functions. the arguments object is only similar to an array but not a real one and it doesn't include any of the array functions except of length() we can pass any parameters we'd like and it automatically pass them as an arguments.

Read more

javascript overloads

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript overloads there's no real overloads, we can or cannot pass parameters to the function, no exception will be thrown and any javascript parameter is an optional. use the || to set defaults whenever no param supplied (null or undefined). we can use private defaults object for a better convenience. - e.g - function myObject(param1, param2, param3, param4) { var defaults =.

Read more

javascript override

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP / prototype   /   No Comments
26
Jan
2016

javascript override function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } Person.prototype.sayYourName = function () { console.log(this.firstName + ' ' + this.lastName); } // override 'toString' Person.prototype.toString = function () { return 'My Name is ' + this.firstName + ' ' + this.lastName }; var person = new Person('Roby', 'Cohen'); // override sayYourName method (change the reference) // only for the current instance person.sayYourName = function.

Read more

javascript inheritance

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / prototype   /   No Comments
26
Jan
2016

javascript inheritance using prototype - best practice: (see 'prototype' above) using reference to the base class example: function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; this.sayYourName = function () { console.log(this.firstName + ' ' + this.lastName); } } function Employee(firstName, lastName, salary) { var parent = new Person(firstName, lastName); // inheritance by reference var salary = salary; // data member this.sayYourSalary = function() { console.log(salary); } this.sayYourName = function() { parent.sayYourName(); console.log('i make.

Read more

javascript prototype

Posted by: RcBuilder  /   Category: class / function / Object / OOP / prototype   /   No Comments
26
Jan
2016

javascript prototype * use prototype to save CPU usage and Memory consumption by defining the object functions directly on it - e.g - function Person(firstName, lastName) { this.firstName = firstName; this.lastName = lastName; } // this 'sayYourName' method will create only once for all Person instances // instead of per each instance - less CPU usage (no need to create it per instance) //.

Read more

javascript object properties access using []

Posted by: RcBuilder  /   Category: Array / class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript object properties access using syntax var dictionary = {}; dictionary = 'AAA'; dictionary = 'BBB'; dictionary = 'CCC'; console.log(dictionary); // BBB console.log(dictionary.B); // BBB note! in the example above, we created an object with 3 properties A,B and.

Read more

javascript arrays

Posted by: RcBuilder  /   Category: Array / JAVASCRIPT / OOP   /   No Comments
26
Jan
2016

javascript arrays structure: - var arr = ; data types: arrays can hold any type of objects, not necessarily the same for all organs they can be consisted of mixed types (string, int, function, custom objects etc.) example: var arr = ; console.log(arr); // hello world console.log(arr); // 23 console.log(arr); // 400.31 var fun = arr; fun('Roby'); // this will log 'hello again Roby' to the console arr();.

Read more

javascript constructor

Posted by: RcBuilder  /   Category: class / function / JAVASCRIPT / Object / OOP   /   No Comments
26
Jan
2016

javascript constructor constructor in javascript located within the function itself without specific declaration it will be executed whenever the 'new' keyword will be used for creating an instance of the object e.g function Person() { // do something here ... } - or - function Person() { function Init(){ // do something here ... } Init(); } var person = new Person(); // this will activate the constructor tip! we can.

Read more
  • פיתוח מערכות
  • פתרונות טכנולוגים
  • קידום אתרים
  • בניית אתרים