From the course: JavaScript: Best Practices for Functions and Classes
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Foundational practice: Always use strict mode - JavaScript Tutorial
From the course: JavaScript: Best Practices for Functions and Classes
Foundational practice: Always 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 the 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 I'll use const for my variable, just for a placeholder location and then I'll console.log it. So const city = 'Chicago' and console.log(city). So I'll save that and I run live server on my HTML page. That opens up in…
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.