Bongani  Ngema

Bongani Ngema


Why I Still Don’t Like Classes in JavaScript

The this parameter, privacy with classes, and factory functions are just a few pitfalls

A few years ago, I wrote an article pointing out the reasons why I didn’t like classes in JavaScript and I  preferred using factory functions. Three years later, I can still say that I don’t like classes in JavaScript and I use them only as an exception when there are no alternatives.

The good news is that many of the class-related problems have been solved. This is great because there are still applications using them, so now there are fewer things to worry about.

Privacy With Classes

Class properties are public by default. That means we can access and modify any of the properties of an object created with a class. However, the hash (#) prefix now allows us to define private properties.

The # is a part of the property name. It is used for both declaring and accessing such a field.

Private fields are accessible only inside the class . Below is an example of the Counter  class encapsulating the count  field:

class Counter {

  constructor() {
    this.#count = 0;

    this.#count += 1;
    return this.#count;

    this.#count -= 1;
    return this.#count;

const counter = new Counter();
counter.increment(); //1
counter.increment(); //2
counter.increment(); //3
counter.decrement(); //2

#react #nodejs #programming #javascript #node

What is GEEK

Buddha Community

Why I Still Don’t Like Classes in JavaScript


Tủ locker ABS w600 khối gồm có 24 ngăn đều nhau, cánh sắt mở sử dụng khóa thông minh , tay nắm và có thêm tấm chia ngăn, trên mỗi cánh cửa được dập 1 bảng tên nhân viên và 1 lỗ thông gió

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên



tủ sắt nhiều ngăn

tủ đựng đồ nhân viên

tủ locker

tủ sắt locker


Lawrence  Lesch

Lawrence Lesch


Superdom: Better and Simpler ES6 DOM Manipulation


You have dom. It has all the DOM virtually within it. Use that power:

// Fetch all the page links
let links = dom.a.href;

// Links open in a new tab = '_blank';

Only for modern browsers

Getting started

Simply use the CDN via

<script src=""></script>

Or use npm or bower:

npm|bower install superdom --save


It always returns an array with the matched elements. Get all the elements that match the selector:

// Simple element selector into an array
let allLinks = dom.a;

// Loop straight on the selection
dom.a.forEach(link => { ... });

// Combined selector
let importantLinks = dom['a.important'];

There are also some predetermined elements, such as id, class and attr:

// Select HTML Elements by id:
let main =;

// by class:
let buttons = dom.class.button;

// or by attribute:
let targeted =;
let targeted = dom.attr['target="_blank"'];


Use it as a function or a tagged template literal to generate DOM fragments:

// Not a typo; tagged template literals
let link = dom`<a href="">Google</a>`;

// It is the same as
let link = dom('<a href="">Google</a>');

Delete elements

Delete a piece of the DOM

// Delete all of the elements with the class .google
delete;   // Is this an ad-block rule?


You can easily manipulate attributes right from the dom node. There are some aliases that share the syntax of the attributes such as html and text (aliases for innerHTML and textContent). There are others that travel through the dom such as parent (alias for parentNode) and children. Finally, class behaves differently as explained below.

Get attributes

The fetching will always return an array with the element for each of the matched nodes (or undefined if not there):

// Retrieve all the urls from the page
let urls = dom.a.href;     // #attr-list
  // ['', '', ...]

// Get an array of the h2 contents (alias of innerHTML)
let h2s = dom.h2.html;     // #attr-alias
  // ['Level 2 header', 'Another level 2 header', ...]

// Get whether any of the attributes has the value "_blank"
let hasBlank =;    // #attr-value
  // true/false

You also use these:

  • html (alias of innerHTML): retrieve a list of the htmls
  • text (alias of textContent): retrieve a list of the htmls
  • parent (alias of parentNode): travel up one level
  • children: travel down one level

Set attributes

// Set target="_blank" to all links = '_blank';     // #attr-set
dom.class.tableofcontents.html = `
  <ul class="tableofcontents">
    ${ => `
        <a href="#${}">

Remove an attribute

To delete an attribute use the delete keyword:

// Remove all urls from the page
delete dom.a.href;

// Remove all ids


It provides an easy way to manipulate the classes.

Get classes

To retrieve whether a particular class is present or not:

// Get an array with true/false for a single class
let isTest = dom.a.class.test;     // #class-one

For a general method to retrieve all classes you can do:

// Get a list of the classes of each matched element
let arrays = dom.a.class;     // #class-arrays
  // [['important'], ['button', 'cta'], ...]

// If you want a plain list with all of the classes:
let flatten = dom.a.class._flat;     // #class-flat
  // ['important', 'button', 'cta', ...]

// And if you just want an string with space-separated classes:
let text = dom.a.class._text;     // #class-text
  // 'important button cta ...'

Add a class

// Add the class 'test' (different ways)
dom.a.class.test = true;    // #class-make-true
dom.a.class = 'test';       // #class-push

Remove a class

// Remove the class 'test'
dom.a.class.test = false;    // #class-make-false


Did we say it returns a simple array?

dom.a.forEach(link => link.innerHTML = 'I am a link');

But what an interesting array it is; indeed we are also proxy'ing it so you can manipulate its sub-elements straight from the selector:

// Replace all of the link's html with 'I am a link'
dom.a.html = 'I am a link';

Of course we might want to manipulate them dynamically depending on the current value. Just pass it a function:

// Append ' ^_^' to all of the links in the page
dom.a.html = html => html + ' ^_^';

// Same as this:
dom.a.forEach(link => link.innerHTML = link.innerHTML + ' ^_^');

Note: this won't work dom.a.html += ' ^_^'; for more than 1 match (for reasons)

Or get into genetics to manipulate the attributes: = '_blank';

// Only to external sites:
let isOwnPage = el => /^https?\:\/\/mypage\.com/.test(el.getAttribute('href')); = (prev, i, element) => isOwnPage(element) ? '' : '_blank';


You can also handle and trigger events:

// Handle click events for all <a> = e => ...;

// Trigger click event for all <a>;


We are using Jest as a Grunt task for testing. Install Jest and run in the terminal:

grunt watch

Download Details:

Author: franciscop
Source Code: 
License: MIT license

#javascript #es6 #dom 

Đặc biệt, bên cạnh một hệ thống tủ locker, các bộ khóa tủ là sự kết hợp hoàn hảo, hỗ trợ công tác bảo quản tư trang và lưu trữ hồ sơ quan trọng tại nơi công sở hiệu quả hơn.

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên


tủ locker

tu locker gia re

tủ cá nhân locker

tủ sắt nhiều ngăn

tủ đựng đồ nhân viên


tủ locker

Hệ thống tủ locker trong trường học giúp cho các học sinh sinh viên có một môi trường học tập hiện đại, thoải mái và an toàn hơn.

#tủ_locker #tủ_sắt_locker #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên



tủ đựng đồ nhân viên

tủ locker

tủ sắt locker



tu locker


Sự hiện diện của giải pháp Smart Locker, như một nâng tầm dịch vụ, sẽ giúp khách hàng chứa đựng tư trang trước khi thoải mái tận hưởng thời gian mua sắm.

#tủ_locker #tủ_sắt_locker   #locker #tu_sat_locker #tu_locker #tủ_locker_sắt #tủ_nhân_viên #tu_locker_sat #tủ_locker_giá rẻ #tu_locker_gia_re #tủ_cá_nhân_locker #tủ_sắt_nhiều_ngăn #tủ_đựng_đồ_nhân_viên



tủ sắt nhiều ngăn

tủ đựng đồ nhân viên

tủ locker

tủ sắt locker