Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
academy
tutorials
reactjs
es6-demos
Commits
4d3ccafa
Commit
4d3ccafa
authored
5 years ago
by
Kerem Çubuk
Browse files
Options
Download
Email Patches
Plain Diff
Update: syntax
parent
f0613d6b
master
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README.md
+9
-9
README.md
solution/operations.js
+10
-10
solution/operations.js
with
19 additions
and
19 deletions
+19
-19
README.md
+
9
-
9
View file @
4d3ccafa
...
...
@@ -162,21 +162,21 @@ These components put together are termed as the data members of the class.
```
javascript
class
Person
{
constructor
(
fname
,
lname
,
age
)
{
this
.
_fn
ame
=
fname
;
this
.
_ln
ame
=
lname
;
this
.
_a
ge
=
age
;
this
.
firstN
ame
=
fname
;
this
.
lastN
ame
=
lname
;
this
.
pA
ge
=
age
;
}
get
name
()
{
return
this
.
_fn
ame
.
toUpperCase
();
return
this
.
firstN
ame
.
toUpperCase
();
}
set
name
(
fname
)
{
this
.
_fn
ame
=
fname
;
this
.
firstN
ame
=
fname
;
}
get
fullname
()
{
return
this
.
_fn
ame
+
'
'
+
this
.
_ln
ame
;
return
this
.
firstN
ame
+
'
'
+
this
.
lastN
ame
;
}
formatted
()
{
return
'
Name is:
'
+
this
.
_fn
ame
;
return
'
Name is:
'
+
this
.
firstN
ame
;
}
}
...
...
@@ -207,7 +207,7 @@ You do so by using the `${...}` syntax.
function
templates
()
{
let
people
=
[
new
Person
(
'
Murat
'
,
'
Karakas
'
,
37
),
new
Person
(
'
Faruk
'
,
'
Yazici
'
,
28
)];
for
(
let
person
of
people
)
{
console
.
log
(
`Fullname:
${
person
.
fullname
}
, Age:
${
person
.
_a
ge
}
`
);
console
.
log
(
`Fullname:
${
person
.
fullname
}
, Age:
${
person
.
pA
ge
}
`
);
}
}
```
...
...
@@ -269,7 +269,7 @@ function arrowFunctionExpression() {
// Arrow functions used inside an Array filter and map
function
arrowFunctionMapFilter
()
{
let
people
=
[
new
Person
(
'
Sedat
'
,
'
Öztürk
'
,
24
),
new
Person
(
'
Murat
'
,
'
Karakas
'
,
37
),
new
Person
(
'
Faruk
'
,
'
Yazici
'
,
27
)];
var
fullnames
=
people
.
filter
(
p
=>
p
.
_a
ge
>=
25
).
map
(
p
=>
p
.
fullname
);
var
fullnames
=
people
.
filter
(
p
=>
p
.
pA
ge
>=
25
).
map
(
p
=>
p
.
fullname
);
console
.
log
(
fullnames
);
}
```
...
...
This diff is collapsed.
Click to expand it.
solution/operations.js
+
10
-
10
View file @
4d3ccafa
...
...
@@ -46,21 +46,21 @@ function generatorConsume() {
class
Person
{
constructor
(
fname
,
lname
,
age
)
{
this
.
_fn
ame
=
fname
;
this
.
_ln
ame
=
lname
;
this
.
_a
ge
=
age
;
this
.
firstN
ame
=
fname
;
this
.
lastN
ame
=
lname
;
this
.
pA
ge
=
age
;
}
get
name
()
{
return
this
.
_fn
ame
.
toUpperCase
();
return
this
.
firstN
ame
.
toUpperCase
();
}
set
name
(
fname
)
{
this
.
_fn
ame
=
fname
;
this
.
firstN
ame
=
fname
;
}
get
fullname
()
{
return
this
.
_fn
ame
+
'
'
+
this
.
_ln
ame
;
return
this
.
firstN
ame
+
'
'
+
this
.
lastN
ame
;
}
formatted
()
{
return
'
Name is:
'
+
this
.
_fn
ame
;
return
'
Name is:
'
+
this
.
firstN
ame
;
}
}
...
...
@@ -75,14 +75,14 @@ function classes() {
console
.
log
(
person
.
name
)
console
.
log
(
person
.
fullname
)
// Setter example
person
.
_fn
ame
=
'
Murat
'
person
.
firstN
ame
=
'
Murat
'
console
.
log
(
person
.
name
)
}
function
templates
()
{
let
people
=
[
new
Person
(
'
Murat
'
,
'
Karakas
'
,
37
),
new
Person
(
'
Faruk
'
,
'
Yazici
'
,
28
)];
for
(
let
person
of
people
)
{
console
.
log
(
`Fullname:
${
person
.
fullname
}
, Age:
${
person
.
_a
ge
}
`
);
console
.
log
(
`Fullname:
${
person
.
fullname
}
, Age:
${
person
.
pA
ge
}
`
);
}
}
...
...
@@ -98,7 +98,7 @@ function arrowFunctionMapFilter() {
console
.
log
(
'
---arrowFunctionMapFilter---
'
)
let
people
=
[
new
Person
(
'
Sedat
'
,
'
Öztürk
'
,
24
),
new
Person
(
'
Murat
'
,
'
Karakas
'
,
37
),
new
Person
(
'
Faruk
'
,
'
Yazici
'
,
27
)];
var
fullnames
=
people
.
filter
(
p
=>
p
.
_a
ge
>=
25
).
map
(
p
=>
p
.
fullname
);
var
fullnames
=
people
.
filter
(
p
=>
p
.
pA
ge
>=
25
).
map
(
p
=>
p
.
fullname
);
console
.
log
(
fullnames
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help