Outils pour utilisateurs

Outils du site


Panneau latéral

webdev:javascript:basics

Ceci est une ancienne révision du document !


Basics

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

Object copy and references

	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]
	}

Get the length of an object (ES5)

var size = Object.keys(myObj).length;
webdev/javascript/basics.1541439782.txt.gz · Dernière modification: 05/11/2018 18:43 de dolo