JavaScript and P5js

Hello. I know that p5.js is just a library. However, do I get it right, that I can use all classical java script features such as prototyping, and others with p5.js?

What I mean is this: processing is based on Java, however there are things done behind the scene so that you need more code to make it a genuine Java program, so to say.

I am just beginning to learn how to program on JavaScript, so I wanted to know if p5js to JavaScript is the same as Processing to Java?

Answers

  • edited January 2016

    ... so I wanted to know if p5js to JavaScript is the same as Processing to Java?

    I'd say very so! ~O)

    ... that I can use all classical java script features such as prototyping, and others with p5.js?

    Yup! :D

  • Does it mean I won't be able to use JavaScript objects and other such stuff.

  • I dunno where you're getting all those doubts from? :-??
    p5.js is a library written in JS. We can use p5.js via JS or any other language which transpiles in JS.

  • My being bad, just didn't read your response to the end (for some strange reason I didn't see it at first).

    Just I am reading a book about Java now, and they use the following syntax var abc = function () {}

    Which is different from how functions are defined in the p5js reference. This is why I had doubts, thanks again.

  • edited January 2016 Answer ✓

    ... (for some strange reason I didn't see it at first).

    I was editing my answer in less than 1 minute after published.
    Seems like you were too fast to read it! :))

    Just I am reading a book about Java now, ...

    Hmm... Wasn't it about JS? :|

    Which is different from how functions are defined in the p5js reference.

    Those p5.js examples were just using the easiest way available in JS for defining functions.
    As you've already noticed there are more! >-)

    Those are called function "declaration or statement":
    https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function

    ... the following syntax var abc = function () {}

    That 1 is an anonymous function "expression":
    https://developer.Mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/function

Sign In or Register to comment.