Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
Loading…
Code Lab is in development. New lessons and improvements are on the way. Progress can be deleted.
JAVASCRIPT TEXT / CHAPTER 03 / Learn / LESSON 02
Second class. String methods return a new string — the original does not change unless you reassign.
trim() removes leading and trailing spaces. includes(sub) returns true/false whether the substring appears. slice(start, end) takes a segment: start included, end excluded.
Mini example:
const raw = " rent "; const clean = raw.trim(); console.log(clean.includes("rent")); console.log(clean.slice(0, 3));
Common mistake: expecting trim to change raw without assignment; or including end in the slice result. We do not use split/join yet.
Methods return a new string.
DATA STANDBY
›