Home / Interview / Less :: General Questions

Interview :: Less

21) What is the purpose of e() function in Less?

The role of e() function is to escape a value from the Less compiler.

22) How can you create a loop structure in Less?

When recursive mixins are combined with Pattern matching and guard expressions, it can create various iterative/loop structures.

23) What is the best way to pre-compile a Less into CSS?

The easiest way to pre-compile a Less into CSS is to use Less.js with Node.js where Less.js run outside the browser.

24) What is the use of Namespaces and Accessors in Less?

The namespaces were used to group the Mixins under a common name. You can perform Encapsulation with the help of Namespaces and Accessors in the Less file.

For example:

25) Define scope in the context of variables in LESS programming language.

The scope of variables refers to the place where the variables exist. The variables were searched in the local scope first. If it is not in the local scope, then the compiler search in the parent scope.

For example:

In the above Less document variable a is defined inside the class with value 20 and variable with the same name is also defined outside the class with value 15. When the compiler executes this Less document, it searches for the local scope first. Hence the local scope of the variable is used. After the compilation process, CSS file is created having font-size value 20px.

26) What is commenting?

The commenting refers to some text which is understandable by the humans to understand the working of some complex codes in the programming.

27) What is the reaction of the compiler to the comments?

The reaction of the compiler to the comments is nothing. The compiler ignores the comments at the time of compilation of the code.

28) How many types of commenting can be done in the Less document?

Two types of comments are allowed in the Less document, inline comments and block comments. However, if you write inline comments in your code, the compiler ignores it and not adds that code to the CSS file. Only block comments will be added to the CSS file.

29) What is the use of importing in Less programming? How is it done?

The importing is used to import CSS or Less document into the Less document. Importing can be done by including "@import" followed by the address of the CSS or Less file at the beginning of the Less document.

30) What is the use of extend in Less?

The extend is a Less pseudo class which is used to select another selector style in one selector.

For example:

In the above example of extending style class properties have been imported into the properties of h2.