You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**The z-index property in CSS controls the vertical stacking order of elements that overlap. As in, which one appears as if it is physically closer to you. z-index only affects elements that have a position value other than static (the default).**
8
+
9
+
### Why z-index may not give expected results sometimes
10
+
11
+
The element doesn’t have its position set
12
+
One of the other guidelines that determine stacking order is if an element has its position set or not.
13
+
14
+
To set position for an element, add the CSS position property to anything other than static, like relative or absolute. (You can read more about it in this article that I wrote.)
15
+
16
+
According to this rule, positioned elements will display on top of unpositioned elements.
Copy file name to clipboardExpand all lines: Javascript/call-apply-bind/call-function.md
+13-15
Original file line number
Diff line number
Diff line change
@@ -9,22 +9,21 @@ There is not big difference in performance. But we can say call is bit faster as
9
9
### Both call() and apply() are methods we can use to assign the this pointer for the duration of a method invocation.
10
10
11
11
```js
12
-
global.x=10;
13
-
// To run this file in my vs-code or in terminal (i.e. where I am in node env)
14
-
//I have to use global . where as < var x = 10 > will work in browser dev-tool
12
+
global.x=10
13
+
/* To run this file in my vs-code or in terminal (i.e. where I am in node env),
14
+
I have to use global . where as < var x = 10 > will work in browser dev-tool
15
15
16
-
//var x = 10
16
+
var x = 10*/
17
17
18
-
var o = { x:15 };
18
+
var o = { x:15 }
19
19
20
-
functionf() {
21
-
console.log(this.x);
20
+
functionf() {
21
+
console.log(this.x)
22
22
}
23
23
24
-
f(); // => 10
25
-
26
-
f.call(o); // => 15
24
+
f() // => 10
27
25
26
+
f.call(o) // => 15
28
27
```
29
28
30
29
The first invocation of f() will display the value of 10, because this references the global object. The second invocation (via the call method) however, will display the value 15. 15 is the value of the x property inside object o.
@@ -41,19 +40,18 @@ A> https://stackoverflow.com/questions/1986896/what-is-the-difference-between-ca
41
40
42
41
### The value of this can never be null or undefined when a function is called. When null or undefined is supplied as the receiver to call() or apply(), the global object is used as the value for receiver instead.
43
42
44
-
45
43
B> The apply function is used to call another function, with a given context and arguments, provided as an array. The min and max functions can take an arbitrary number of input arguments: Math.max(val1, val2, ..., valN)
46
44
47
45
So if we call:
48
46
49
-
``Math.min.apply(Math, [1,2,3,4]);``
47
+
`Math.min.apply(Math, [1,2,3,4]);`
50
48
51
49
The apply function will execute:
52
50
53
-
``Math.min(1,2,3,4);``
51
+
`Math.min(1,2,3,4);`
54
52
55
53
Note that the first parameter, the context, is not important for these functions since they are static, they will work regardless of what is passed as the context.
56
54
57
-
### Special note - With ES6, the equivalent code for the above is ``Math.max(...Arr)``
55
+
### Special note - With ES6, the equivalent code for the above is `Math.max(...Arr)`
58
56
59
-
Replacing “Math” with “null” would output same output
57
+
Replacing “Math” with “null” would output same output
0 commit comments