Skip to main content

Functions

  • Chapter
  • First Online:
Learn JavaScript with p5.js
  • 2606 Accesses

Abstract

Functions are primary building blocks of JavaScript. They allow us to write programs in a more efficient and scalable manner. Functions help us to manage complexity by containing and grouping operations under a single executable name. We already know how to call functions by using the p5.js predefined functions such as ellipse or background. We even declared our own functions as p5.js forces us to put our code into two function declarations: setup and draw. If we wanted to create our own functions, we would follow the same convention we have been using for the creation, or declaration, of these functions.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

eBook
USD 16.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 16.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Author information

Authors and Affiliations

Authors

Rights and permissions

Reprints and permissions

Copyright information

© 2018 Engin Arslan

About this chapter

Check for updates. Verify currency and authenticity via CrossMark

Cite this chapter

Arslan, E. (2018). Functions. In: Learn JavaScript with p5.js. Apress, Berkeley, CA. https://doi.org/10.1007/978-1-4842-3426-6_8

Download citation

Publish with us

Policies and ethics