Google News
logo
p5.js - Interview Questions
What is the difference between P5.js and JavaScript?
JavaScript is a core language that provides all the features to build any functionalities into browsers. It can use Loop, Function, Conditional, DOM Manipulation, events, canvas, etc. Hence, by using it to develop and design any framework.

p5.js is a library of JavaScript. P5.js is running on Pure JavaScript provides some functions that make JavaScript user life easy to draw in the web.
 
Example :
function setup() {
  createCanvas(400, 400); //Canvas size 400*400
}
  
function draw() {
  background('blue'); //background color blue
}
Output :
p5.js
setup() : It is the statements in the setup() function. It executes once when the program begins. createCanvas must be the first statement.

draw() : The statements in the draw() are executed until the program is stopped. Each statement is executed in sequence and after the last line is read, the first line is executed again.
Advertisement