Skip to main content

Home/ javascript/ Group items tagged use

Rss Feed Group items tagged

Javier Neira

InfoQ: ECMAScript 5 released - 1 views

  • 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).
  • var i=3 is needed
  • ...10 more annotations...
  • 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
Javier Neira

Perfection kills » Understanding delete - 3 views

  • All because it’s not possible to delete variables in Javascript. At least not when declared in such way.
  • It’s almost as if Firebug follows some other rules of deletion. It is Firebug that has led Stoyan astray! So what is really going on here?
  • we need to understand how delete operator works in Javascript: what exactly can and cannot be deleted and why.
  • ...35 more annotations...
  • var o = { x: 1 }; delete o.x; // true o.x; // undefined
  • var x = 1; delete x; // false x; // 1
  • function x(){} delete x; // false typeof x; // "function"
  • Note that delete only returns false when a property can not be deleted.
  • variable instantiation and property attributes
  • Global code, Function code and Eval code.
  • When a source text is treated as a Program, it is executed in a global scope, and is considered a Global code.
  • Anything that’s executed directly within a function is, quite obviously, considered a Function code. In browsers, content of event attributes (e.g. <p onclick="...">) is usually parsed and treated as a Function code.
  • text that’s supplied to a built-in eval function is parsed as Eval code. We will soon see why this type is special.
  • And now that we know the difference between property assignment and variable declaration — latter one sets DontDelete, whereas former one doesn’t — it should be clear why undeclared assignment creates a deletable property:
  • As you can see, execution contexts can logically form a stack. First there might be Global code with its own execution context; that code might call a function, with its own execution context; that function could call another function, and so on and so forth. Even if function is calling itself recursively, a new execition context is being entered with every invocation.
  • Every execution context has a so-called Variable Object associated with it. Similarly to execution context, Variable object is an abstract entity, a mechanism to describe variable instantiation. Now, the interesing part is that variables and functions declared in a source text are actually added as properties of this Variable object.
  • When control enters execution context for Global code, a Global object is used as a Variable object. This is precisely why variables or functions declared globally become properties of a Global object:
  • The behavior is actually very similar: they become properties of Variable object. The only difference is that when in Function code, a Variable object is not a Global object, but a so-called Activation object. Activation object is created every time execution context for Function code is entered.
  • and a special Arguments object (under arguments name). Note that Activation object is an internal mechanism and is never really accessible by program code.
  • within Eval code are created as properties of calling context’s Variable object. Eval code simply uses Variable object of the execution context that it’s being called within:
  • Now that it’s clear what happens with variables (they become properties), the only remaining concept to understand is property attributes. Every property can have zero or more attributes from the following set — ReadOnly, DontEnum, DontDelete and Internal. These attributes serve as sort of flags — an attribute can either exist on a property or not. For the purposes of today’s discussion, we are only interested in DontDelete.
  • When declared variables and functions become properties of a Variable object — either Activation object (for Function code), or Global object (for Global code), these properties are created with DontDelete attribute. However, any explicit (or implicit) property assignment creates property without DontDelete attribute. And this is essentialy why we can delete some properties, but not others:
  • Special arguments variable (or, as we know now, a property of Activation object) has DontDelete. length property of any function instance has DontDelete as well:
  • As you might remember, undeclared assignment creates a property on a global object.
  • Execution context When ECMAScript code executes, it always happens within certain execution context.
  • Variables declared within Eval code are actually created as properties without DontDelete:
  • This interesting eval behavior, coupled with another aspect of ECMAScript can technically allow us to delete non-deletable properties. The thing about function declarations is that they can overwrite same-named variables in the same execution context:
  • Note how function declaration takes precedence and overwrites same-named variable (or, in other words, same property of Variable object). This is because function declarations are instantiated after variable declarations, and are allowed to overwrite them
  • If we declare function via eval, that function should also replace that property’s attributes with its own. And since variables declared from within eval create properties without DontDelete, instantiating this new function should essentially remove existing DontDelete attribute from the property in question, making that property deletable (and of course changing its value to reference newly created function).
  • Unfortunately, this kind of spoofing doesn’t work in any implementation I tried. I might be missing something here, or this behavior might simply be too obscure for implementors to pay attention to
  • this.x = 1; delete x; // TypeError: Object doesn't support this action
  • var x = 1; delete this.x; // TypeError: Cannot delete 'this.x'
  • It’s as if variable declarations in Global code do not create properties on Global object in IE.
  • Not only is there an error, but created property appears to have DontDelete set on it, which of course it shouldn’t have:
  • “The global variable object is implemented as a JScript object, and the global object is implemented by the host.
  • Note how this and window seem to reference same object (if we can believe === operator), but Variable object (the one on which function is declared) is different from whatever this references.
  • delete doesn’t differentiate between variables and properties (in fact, for delete, those are all References) and really only cares about DontDelete attribute (and property existence).
  • The moral of the story is to never trust host objects.
  • Few restrictions are being introduced. SyntaxError is now thrown when expression in delete operator is a direct reference to a variable, function argument or function identifier. In addition, if property has internal [[Configurable]] == false, a TypeError is thrown:
yc c

lazytom's FeedJumbler - work your feeds!™ - 1 views

  •  
    Convert a RSS or Atom-based feed into RSS, Atom and/or HTML and JavaScript Merge/splice several RSS or Atom-based feeds into one combined RSS and/or Atom feed Put an RSS feed (or merged feed) on your webpage using an IFrame or JavaScript)
  •  
    * Convert a RSS or Atom-based feed into RSS, Atom and/or HTML and JavaScript * Merge/splice several RSS or Atom-based feeds into one combined RSS and/or Atom feed * Put an RSS feed (or merged feed) on your webpage using an IFrame or JavaScript) Optionally, you can also register to get a personalized page where you can keep track of your merged feeds.
mahesh 1234

Java Tutorial - javatpoint - 0 views

  •  
    Java is not only a programming language but a platform also. Let's learn where it is used and what application we can create through java.
mahesh 1234

JSP Tutorial, JavaServer Pages Technology (JSP) - javatpoint - 0 views

  •  
    JSP Tutorial - Javatpoint website provides you a complete JSP tutorial with practical programming examples and easy steps using this beginner's tutorial containing basic to advanced knowledge of Java JSP Technology including Form Data, HTTP Request Header, Response Header, Scripting elements, Directive elements, Custom tags, Cookies Handling and Session Tracking.
qualitypoint Tech

Arts Point - Web Application for connecting Artists, Promoters and Viewers of Live Musi... - 1 views

  •  
    This Arts Point script is useful for connecting Promoters, Artists and Viewers of Live Music Events. Promoters can advertise about their Live music events in this application, and Artists can apply for any event of their choice. The promoters can choose suitable Artists for their Events. The viewers can search their favorite live music events easily.
qualitypoint Tech

Offer to buy exclusive rights of our Arts Point Script - 0 views

  •  
    Are you a web master or a company looking for a script which can help you earn money either by showing advertisements or by providing paid service?\n\nIf your answer is "yes", this blog post will be more useful for you.
yc c

ColorPicker 0.6 - 0 views

  •  
    This colorPicker is a light weight all-rounder (only ~46k incl. all 16 files) that can display and let you choose the entire color palette (~16.78 mil. colors) in 6 different color modes (+3 extra modes in RGB). This highly customizable and easy to install app comes in 4 different sizes (from 151 x 87 pixels to 405 x 302 pixels) and therefore different feature levels so you can use it for every supposable cause from 'easy choice' to 'professional determination'. That's probably all you'll ever need to let your clients choose the right color.
Julian Knight

jQuery and Google Maps Tutorial: #1 Basics: jQuery, Google Maps - 0 views

  •  
    "There are many times I want to leverage jQuery's strengths to create a custom Google Maps mashup. In this tutorial, I will walk you through how to get started using jQuery inside the Google Maps environment. I will assume nothing, and explain each piece in detail."
Mike Chelen

Bespin » Code in the Cloud - 0 views

  •  
    Bespin is a Mozilla Labs experiment on how to build an extensible Web code editor using HTML 5 technology.
Ivan Pavlov

joose-js - Google Code - 0 views

  • Joose is a self-hosting meta object system for JavaScript with support for classes, inheritance, mixins, traits, method modifiers and more. Joose makes object-oriented programming with JavaScript easy, declarative and very productive. The Joose meta-object system is multi-paradigm. It supports class-based and prototype-based programming styles as well as class-based inheritance and role-based extention. The Joose framework has been successfully used in multiple production systems for twelve months now and has been proven to be very stable. Joose is being tested using an automated unit-test suite that is being run in all major browsers (Firefox, IE, Safari, Opera and Chrome).
Ivan Pavlov

Persevere: JSON Storage / Application Server - 0 views

  • The Persevere project is an open source set of tools for persistence and distributed computing using intuitive standards-based JSON interfaces of HTTP REST, JSON-RPC, JSONPath, and HTTP Channels. The core of the Persevere project is the Persevere Server. The Persevere server includes a Persevere JavaScript client, but the standards-based interface is intended to be used with any framework or client.
Ivan Pavlov

Session variables without cookies - 0 views

  • I've made a small script that let you use JavaScript session variables without using cookies. It will let you store 2 MB of data, with much less hassle than a cookie based solution.
Mike Chelen

webchat2 - Google Code - 0 views

  •  
    A fast, highly interactive, fun chat application using a javascript, comet (real time push communication), ajax (async posting of information) modern web interface, and a custom PHP based backend daemon that interfaces between the (web) frontend and the IRC backend server.
Mike Chelen

Aptana Jaxer - 0 views

  •  
    # Use your Ajax, HTML, JavaScript and DOM skills server-side # Integrate with databases, file systems, networks and more # Just tag your JavaScript code to run on the server, the client, or both # Easily deploy your Jaxer apps to Aptana Cloud from within Studio
Mike Chelen

passpack - Google Code - 0 views

  •  
    Passpack Host-Proof Hosting is a package who's aim is to give Ajax programmers the libraries they need to build a Host-Proof Hosting application. A number of pre-existing libraries have been modified and grouped together under the Passpack namespace in order to facilitate use.
Julian Knight

Home - chain.js - GitHub - 0 views

  •  
    JQuery plugin that allows creation of html client-side using templates. Integration with jquery makes the process simple and compatible with events so that DOM manipulation stays consistent. See also interaction.js at http://github.com/raid-ox/interaction.js/wikis. This extends some easy interactions to chain such as drag and drop and sorting. Also usage tutorial at: http://zparse.net.tc/
‹ Previous 21 - 40 of 113 Next › Last »
Showing 20 items per page