From the course: JavaScript: Best Practices for Code Formatting
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Foundational practice: Use strict mode - JavaScript Tutorial
From the course: JavaScript: Best Practices for Code Formatting
Foundational practice: Use strict mode
- [Instructor] No matter which other practices are in your style guide, or what modern JavaScript features you may be using, your first step when writing code should be to ensure that you're working in strict mode. Indicating that code should be interpreted in strict mode specifies to user agents like browsers that they should treat code literally as written, and throw an error if the code doesn't make sense. Without strict mode turned on, user agents often go through a series of modifications to problematic code in an attempt to get it to make sense. In the start file for this video, I'm going to create and then log a variable. My idea is to build an app to get a user's location and identify nearby events. And for a placeholder location, I'm going to create a const called city, and set that to Chicago. And then I'm going to console.log that. And I'm going to save that file, and then switching over to my HTML file…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.