How to list properties of object in Javascript

This is a task that looks easy at first sight, but when you start to actually do it, things becomes a little bit complex.

The naive way is a simple for in loop.

How to use querySelector the built in CSS selector API in Javascript

Since the ubiquitous of jQuery's usage, many of you may not know there are some built in CSS selector APIs in javascipt core.

The are querySelector and querySelectorAll. When you don't have jQuery support, you can use them .

How to add input fields dynamically with jQuery example

In many applications especially HTML form, users need to add items dynamically. For example, user want to submit URLs and their description to share it. User may have variable number of links to submit, the fixed number of input fields will be inconvenient.

This post shows how to implement add and remove input fields dynamically with jQuery. Our example also support multiple items that need to be added dynamically by provide customized field type.

This post shows how to implement add and remove input fields dynamically with jQuery. Our example also .

Load Javascript dynamically with dependencies

In last post Implements a deferred object in Javascript, we implemented a deferred object, this tool can be used in loading dependencies for a Javascript file.

A Javascript file must wait for all its dependencies loaded and then initialize itself.

Implements a deferred object in Javascript

The deferred object is very useful when deal with asynchronous event in Javscript like load js or send ajax request.

In a distributed environment like Web application, the network delay is unavoidable and uncontrollable, many things just can not finish immediately, but suspend the application is also unacceptable for users.

__proto__ and prototype in Javascript

The __proto__ and prototype are two key properties in Javascript. Its little bit hard to grasp at first. But just remember some simple rules, you will be able to get it very quick.

Including function and instance. Because function is also an object.

How to use comma in Javascript

The document of comma operator is very simple.

I think the document means this.

Using test to facilitate reading code

Sometimes when you read the source code, its hard to understand it in static environment, because you don't know the runtime value of variables. For example, this is a Javascript function .

What this function do? Its not so clear at first sight.

Javascript Pattern: Using closure as a cache

Sometimes, you want to cache the result of a calculation, and use it directly when next time call. With Javascript closure, you can do this easily.

Here is an example.

Javascript for in loops and hasOwnProperty

There are a lot of Javascript code using for in loops with hasOwnProperty. For example.

Because the for in loop will list all properties in the object, includes the prototype property.

Previous Page 1 2 3 Next Page