Outils pour utilisateurs

Outils du site


Panneau latéral

webdev:javascript:basics

Ceci est une ancienne révision du document !


Basics

Get the length of an object (ES5) :

var size = Object.keys(myObj).length;

Events

  • On Chrome e.originalEvent.screenX take different values than e.originalEvent.clientX, unlike Firefox.

Promises

Check if a variable exist in javascript without getting an error

Source

if( typeof google_step != 'undefined')
{
	// ...
}

Objects

	var tmpDisable = {};
	var lastTmpDisable = {};

	lastTmpDisable = tmpDisable; // Any change made to any of these object will be on both because they're references

	// If we declare it this way a new object is created
	for(var key in tmpDisable)
	{
		lastTmpDisable[key] = tmpDisable[key]
	}
webdev/javascript/basics.1541439711.txt.gz · Dernière modification: 05/11/2018 18:41 de dolo