What is the difference between JavaScript methods and my own custom functions?

Where are the methods stored?

Are the methods properties that are automatically added to each file type?

For example, does a string automatically inherit certain properties (methods like toUpperCase(), length property…) like a constructor does in a class?

Are the file types (strings, numbers, booleans…) also objects with properties?

I ask because the use of a period in front of the methods as if you were accessing an object.

Yeah, strings and arrays are special types of objects in Javascript. Their prototypes define certain ‘built in’ methods.

1 Like

Thank You for fast answer!

Are there other data types in JavaScripts that are objects?
For example numbers and booleans?

Woops, technically a string is actually a primitive type, though it still has ‘built in’ methods like an object.

Arrays are objects though.

1 Like

You’re asking good questions! freeCodeCamp does teach a bit about prototypes in later lessons, but since you’re already curious I encourage you to google around and find a description that makes sense to you.

Here’s one that is neat because it has some interactive code widgets: Prototype in JavaScript

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.