Develop ASP.NET, php and Ajax applications in your browserTest and debug code in the cloudInstantly deploy applications to the cloudDiscover and share code
Encoding/Decoding Escape/Unescape These scripts are intended to explain how to "hide" HTML and/or javascript from other people who view your page's source code. It is not foolproof, but it does make it more difficult to read and understand the source code. Due to the nature of how these scripts work, the explanation may seem complicated and drawn out, but be patient and it should make sense once you gain a little experience with them. You don't really have to know the ins-and-outs of these scripts, but it does help you understand how and why they work. So, take a seat and I'll do my best to make this seem as un-complicated as possible.
You can attend our Quiz here.\n\nWe are working on to publish more questions in many topics (e.g mysql, javascript, html,...).\n\nSo, you can bookmark this blog for further reading, or you can subscribe to our blog feed.
In JavaScript, where functions are objects and aren’t declared as part of anything, the object referenced by this is called the function context and is determined by how the function is invoked not by how its declared.
This means that the same function can have different contexts depending on which object calls it.
The introduction of strict mode aims to avoid common coding problems in ECMAScript applications. This is achieved with the presence of a lone string literal in a unit (script or function):
"use strict;"
for either the entire script (if at the top of the script) or for a single function (if the first part of a function).
and introducing new variables through eval cannot occu
delete cannot be used against arguments, functions or variables or other properties with the configurable flag set to false
with statements, often a source of errors, are no longer used and considered syntax errors
Functions can no longer have duplicate arguments with the same name
Objects can no longer have duplicate properties with the same name
Access to the global object becomes a runtime error
A new JSON object with parse and stringify to support efficient generation of JSON data; like eval but without the security implications of being able to reduce code
Array now has standard functions, such as indexOf(), map(), filter(), and reduce()
Object now has seal()
and freeze()
Object.getPrototypeof() returns the prototype of the given object
What we want is the ability to define a method dynamically (given a name) that is also a closure over the lexical scope at the point of method definition.
color_name = 'black' Ninja.send(:define_method, 'color') do puts "#{name}'s color is #{color_name}"end
var colorName = "black"; Ninja.prototype['color'] = function () { puts(this.name + "'s color is " + colorName);}
The ubiquity of closures in Javascript is extremely powerful and, as we have seen so far, makes metaprogramming very easy.
You can think of a metaclass as a class definition specific to a single instance of a class.
This means we can add methods to an object’s metaclass without adding the same behavior to all instances of that object’s class.
This means that Javascript does not distinguish between classes/prototypes and instances and, therefore, we can add our desired behavior directly to the instance.