Best Standards

Best Practice && and Standards

Url Standards of Google

Reference: https://developers.google.com/search/docs/crawling-indexing/url-structure (opens in a new tab)

Consider using hyphens to separate words in your URLs, as it helps users and search engines identify concepts in the URL more easily. We recommend that you use hyphens (-) instead of underscores (_) in your URLs.

Recommended: Hyphens (-):

Ex URL :

https://www.example.com/summer-clothing/ (opens in a new tab)

Variable declaration

When to use Var, Let or const

Reference: https://www.freecodecamp.org/news/var-let-and-const-whats-the-difference/ (opens in a new tab)

Var

Var variables can be re-declared and updated. This means that we can do this within the same scope and won't get an error.

var greeter = "hey hi";
var greeter = "say Hello instead";

And this also :

var greeter = "hey hi";
greeter = "say Hello instead";

Let

Let can be updated but not re-declared.

Just like var, a variable declared with let can be updated within its scope.

Unlike var, a let variable cannot be re-declared within its scope.

So while this will work:

let greeting = "say Hi";
greeting = "say Hello instead";

This will return an error:

let greeting = "say Hi";
let greeting = "say Hello instead"; // error: Identifier 'greeting' has already been declared

Const

Const cannot be updated or re-declared.

This means that the value of a variable declared with const remains the same within its scope. It cannot be updated or re-declared.

So if we declare a variable with const, we can neither do this:

const greeting = "say Hi";
greeting = "say Hello instead";// error: Assignment to constant variable. 

Nor this:

const greeting = "say Hi";
const greeting = "say Hello instead";// error: Identifier 'greeting' has already been declared

Every const declaration, therefore, must be initialized at the time of declaration.

This behavior is somehow different when it comes to objects declared with const. While a const object cannot be updated, the properties of this objects can be updated. Therefore, if we declare a const object as this:

const greeting = {
    message: "say Hi",
    times: 4
}

While we cannot do this:

greeting = {
    words: "Hello",
    number: "five"
} // error:  Assignment to constant variable.

We can do this:

greeting.message = "say Hello instead";

This will update the value of greeting.message without returning errors.

Jest standards

description and tests

Description test and it always start with a lower case.

description('our webpage',() => {
    test('add 1 + 2 to equal 3', () => {
        expect(sum(1,2)).tobe(3);
    });
    it('render our page', () => {
        const tree = renderer
        .create(<Link page="https://phpr.link/">phpcreation</Link>)
    .toJSON();
  expect(tree).toMatchSnapshot();
    });
});

It is important to end all lines with ;.