Rolling Shrine
  • Welcome to Rolling Shrine
  • RGB Principles
    • Glory Principles
    • Mission & Vision
    • Values
    • Forte
    • Spirit
    • Coaster Traits
    • Glory Principles in Daily Practices
  • RGB Branding Book
    • Brand Guideline
    • Visual Implementation
    • Brand Story
    • Brand Personality
  • Organization
    • Organization Structure
    • Accountabilities & Responsibilities
      • All Roles
      • Department & Team Leadership
        • Department Head
        • Team Lead
        • Tribe Lead
      • Manager & Project Leadership
        • Program Manager (PgM)
        • Project Manager (PM)
        • Project Leadership
          • Tech Lead
          • Design Lead
      • Project Team
        • Designer
        • Engineer
        • Quality Assurance
        • Web Administrator
      • Traffic Management
      • Archives
        • Project Manager Lead
        • Team Leader
    • Career Grade & Performance Management
    • Competencies Dictionary
  • Onboarding
    • New Coaster Onboarding
    • Project Manager Onboarding
    • Designer Onboarding
    • Engineer Onboarding
    • QA Onboarding
    • Web Administrator Onboarding
  • Production & Project Management
    • Production Pipeline
    • Solution Pipeline & Guideline
  • Design Team
    • Design Team Roles & Responsibilities
    • Information Architecture
    • Web Design System
      • Desktop View Guideline
      • Responsive View Guideline
      • Principle - Typography
      • Sticker Sheets
        • Desktop View Home Page
        • Desktop View All Pages
        • Responsive View Home Page
        • Responsive View All Pages
    • UX Writing
    • Design Audit
    • Mobile UI Technical Guideline
      • Intro: Canvas
      • Foundation
        • Typography
        • Spacing
        • Color
        • Grid & Column
      • Core Components
        • Bottom Navigation Bar
        • Button
        • Grid
        • Header
        • Selection
        • Slider
        • Status Bar
        • Text Input
        • Vertical List
      • Complex Components
      • Layout
      • Design System
      • Design System Checklist
    • Web UI Technical Guideline
      • Design System
      • Design System Checklist
  • Engineering Team
    • Software Testing
    • Git Best Practice
      • Git Commit Best Practice
    • Coding Convention
      • PHP Coding Convention
      • JavaScript Coding Convention
      • Android Coding Convention
    • JSON API Specification
    • GlorySDK for Android
    • GloryKit for iOS
    • QA Team Guideline
    • Engineering Stuff Documents
  • Work From Home
    • Best Practice
  • Documents
  • Coaster Rewards & Appreciation
    • House Party Program
    • Quarterly Award
    • Coaster Loyalty Reward
    • Overtime Appreciation
  • HR
    • Work Hour & Leave Policy
    • HRIS Talenta Onboard
    • Rolling Soft Loan
    • Review Guideline
  • Rolling Daily Log
  • Tribe Leader Guideline
  • Rolling Ekstra Kurikuler
  • COVID-19 Prevention - Studio Protocol
Powered by GitBook
On this page
  • Goal
  • Intro
  • References
  • Objects

Was this helpful?

  1. Engineering Team
  2. Coding Convention

JavaScript Coding Convention

PreviousPHP Coding ConventionNextJSON API Specification

Last updated 5 years ago

Was this helpful?

Goal

A convention to standardize JavaScript coding style.

Intro

We are not reinventing the wheels. We adopt from and adjust accordingly to our preferences.

In this document, we will rewrite the selected specification we adopt and add a few of our preferences. For anything that is not stated in this document, refer to AirBnB JavaScript Style Guide.

References

  • 2.1 Use const for all of your references; avoid using var. eslint: ,

    Why? This ensures that you can’t reassign your references, which can lead to bugs and difficult to comprehend code.

    // bad
    var a = 1;
    var b = 2;
    
    // good
    const a = 1;
    const b = 2;
  • 2.2 If you must reassign references, use let instead of var. eslint:

    Why? let is block-scoped rather than function-scoped like var.

    // bad
    var count = 1;
    if (true) {
      count += 1;
    }
    
    // good, use the let.
    let count = 1;
    if (true) {
      count += 1;
    }

Objects

  • // bad
    const item = new Object();
    
    // good
    const item = {};
  • // bad
    const atom = {
      value: 1,
    
      addValue: function (value) {
        return atom.value + value;
      },
    };
    
    // good
    const atom = {
      value: 1,
    
      addValue(value) {
        return atom.value + value;
      },
    };
  • Why? It is shorter and descriptive.

    const lukeSkywalker = 'Luke Skywalker';
    
    // bad
    const obj = {
      lukeSkywalker: lukeSkywalker,
    };
    
    // good
    const obj = {
      lukeSkywalker,
    };

To be continued. More to come

3.1 Use the literal syntax for object creation. eslint:

3.3 Use object method shorthand. eslint:

3.4 Use property value shorthand. eslint:

AirBnB JavaScript Style Guide
prefer-const
no-const-assign
no-var
no-new-object
object-shorthand
object-shorthand