Module Design Pattern - Beau teaches JavaScript

preview_player
Показать описание
The module design pattern in JavaScript is one of the most used designed pattern for keeping particular pieces of code independent from other parts. Learn how to use it in this quick video!

Code:
More information:

⭐JavaScript Playlists⭐

-
We're busy people who learn to code, then practice by building projects for nonprofits. Learn Full-stack JavaScript, build a portfolio, and get great references with our open source community.

Рекомендации по теме
Комментарии
Автор

A class isn't really the same as a revealing module pattern object. That class syntax has all its members public, and creates instances every time you call it. The module pattern uses closures for private members and only returns one object.

nokomoko
Автор

Without the syntax sugar and prototype orientation it'd look like:

let Module = (() => {
let private = 'secret'

function _privFunc() { console.log('Ayy LMAO') }
function publicFunc() { _privFunc() }

return { publicFunc }
}())

kozmicluis
Автор

Thanks so much! In short you explained what others take an hour to do!

WorkingJ
Автор

is this like object oriented programming in other languages?

funtret
Автор

I think this content is grossly misleading. The "new"-ish Class syntax has little to do with the Module Pattern; the former does nothing in the way of enabling private member as the latter does.

ytwt
Автор

Do browsers support ES6? I thought is wasn't supported fully.

wjrasmussen