Tag: JavaScript
Object Or Array Check in JavaScirpt
Test whether an object is an object or an array if(Object.prototype.toString.apply(arr) === ‘[object Array]’) alert(“Array”) Original Article
A Simple Logging Function for JavaScript
Prints all the arguments of the function. This function uses console.log if firebug is available – else, uses alert. function…
Chainable interface in JavaScript
Creating Chainable interfaces in javascript… (function() { function _init() { return this; } _init.prototype = { “myFunction”: function() { return…
Execute JavaScript files using Rhino
The command to execute a javascript file using rhino. java -jar /path/to/custom_rhino.jar JS_File.js Get Custom Rhino(From Dojo Library)
Install Rhino
Installing Rhino(Javascript interpreter created in java) on Fedora 7 sudo yum install rhino-manual rhino-demo rhino
Scope and Binding in JavaScript
Function x executions in the scope of object y. var Car = function() { this.name = ‘car’; } var Truck…
Find Element’s Position using JavaScript
Find the position of an element using javascript function findPos(obj) { var curleft = curtop = 0; if (obj.offsetParent) {…
Find the Fourth Sunday
Javascript code for finding the fourth sunday in any given month. function findFourthSunday(year,month) { var fourth_sunday = 0; var sunday_count…
Shortest way to create an XMLHttpRequest object
For best results use a framework – like jx http = window.XMLHttpRequest ? new window.XMLHttpRequest : (window.ActiveXObject ? new ActiveXObject(“MSXML2.XMLHTTP”):…
Object or Array
Find whether the given variable is an object,or is an Array? function isArray(testObject) { return testObject && !(testObject.propertyIsEnumerable(‘length’)) && typeof…
Recent Comments