javascript what does use strict do code example

Example 1: javascript use strict

// Whole-Script Strict Mode Syntax
'use strict';
var v = "Hi! I'm a strict mode script!";

Example 2: what does function setup() do in javascript

function setup() {
	create canvas(400, 400)
}

function draw(){
	if(mouseIsPressed){
		fill(0);
}else{
  fill(255)
}
  ellipse(mouseX, mouseY, 80, 80)
}

Example 3: use strict javascript

function doSomething() {
    'use strict';
    ...
}

Example 4: what does return do in javascript

function add(a, b) {
  return a + b; //Return stops the execution of this function
}

var sum = add(5, 24); //The value that was returned got but inside the variable sum

Tags:

Html Example