Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김민재
/
OSS
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
Dexter Jin
2020-02-02 14:56:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7b066cf4a9ffb8477da76960cdab6430755bcff2
7b066cf4
1 parent
1045e502
Experiment07 Updated
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
84 additions
and
285 deletions
Experiments/experiments07/Assignments/01/app.js
Experiments/experiments07/Assignments/01/mymodule.js
Experiments/experiments07/Assignments/02/consumer.js
Experiments/experiments07/Assignments/02/producer.js
Experiments/experiments07/Tutorial/arithmeticOperator.js
Experiments/experiments07/Tutorial/assignmentOperator.js
Experiments/experiments07/Tutorial/bitwiseOperator.js
Experiments/experiments07/Tutorial/comparisonOperator.js
Experiments/experiments07/Tutorial/conditionalOperator.js
Experiments/experiments07/Tutorial/event01/app.js
Experiments/experiments07/Tutorial/event02/app.js
Experiments/experiments07/Tutorial/forStatement.js
Experiments/experiments07/Tutorial/ifelseStatement.js
Experiments/experiments07/Tutorial/logicalOperator.js
Experiments/experiments07/Tutorial/mymodule/app.js
Experiments/experiments07/Tutorial/mymodule/mymodule.js
Experiments/experiments07/Tutorial/switchStatement.js
Experiments/experiments07/Tutorial/typeofOperator.js
Experiments/experiments07/Tutorial/variables.js
Experiments/experiments07/Tutorial/whileStatement.js
Experiments/experiments07/assignment01/assignment01.js
Experiments/experiments07/assignment02/assignment02.js
Experiments/experiments07/assignment03/assignment03.js
Experiments/experiments07/debugging/debugging.js
Experiments/experiments07/Assignments/01/app.js
0 → 100644
View file @
7b066cf
// mymodule.js에 정의된 모듈로 불러서 사용하도록 처리
Experiments/experiments07/Assignments/01/mymodule.js
0 → 100644
View file @
7b066cf
// 아래 2개의 함수를 모듈로 정의하는 것이 필요함
function
add
(
a
,
b
)
{
return
a
+
b
;
}
function
sub
(
a
,
b
)
{
return
a
-
b
;
}
Experiments/experiments07/Assignments/02/consumer.js
0 → 100644
View file @
7b066cf
// Consumer 코드는 변경할 필요 없음
var
Producer
=
require
(
'./producer'
);
var
producer
=
new
Producer
();
producer
.
on
(
'add'
,
function
(
t
)
{
console
.
log
(
'add:'
,
t
);
});
producer
.
start
();
Experiments/experiments07/Assignments/02/producer.js
0 → 100644
View file @
7b066cf
var
inherits
=
require
(
'util'
).
inherits
;
var
EventEmitter
=
require
(
'events'
).
EventEmitter
;
var
Producer
=
function
()
{
if
(
!
(
this
instanceof
Producer
))
return
new
Producer
();
EventEmitter
.
call
(
this
);
}
// inherits를 활용, Producer construct가 EventEmitter Construct를 상속받음
inherits
(
Producer
,
EventEmitter
);
// producer의 start 함수를 재정의
Producer
.
prototype
.
start
=
function
()
{
// Random 스트링을 생성하여 이것을 Event에 실어서 보내야 하는 코드 작성
}
module
.
exports
=
Producer
;
Experiments/experiments07/Tutorial/arithmeticOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
33
;
var
b
=
10
;
var
c
=
"Test"
;
console
.
log
(
"a + b = "
);
result
=
a
+
b
;
console
.
log
(
result
);
console
.
log
(
"a - b = "
);
result
=
a
-
b
;
console
.
log
(
result
);
console
.
log
(
"a / b = "
);
result
=
a
/
b
;
console
.
log
(
result
);
console
.
log
(
"a % b = "
);
result
=
a
%
b
;
console
.
log
(
result
);
console
.
log
(
"a + b + c = "
);
result
=
a
+
b
+
c
;
console
.
log
(
result
);
a
=
a
++
;
console
.
log
(
"a++ = "
);
result
=
a
++
;
console
.
log
(
result
);
b
=
b
--
;
console
.
log
(
"b-- = "
);
result
=
b
--
;
console
.
log
(
result
);
Experiments/experiments07/Tutorial/assignmentOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
33
;
var
b
=
10
;
console
.
log
(
"Value of a => (a = b) => "
);
result
=
(
a
=
b
);
console
.
log
(
result
);
console
.
log
(
"Value of a => (a += b) => "
);
result
=
(
a
+=
b
);
console
.
log
(
result
);
console
.
log
(
"Value of a => (a -= b) => "
);
result
=
(
a
-=
b
);
console
.
log
(
result
);
console
.
log
(
"Value of a => (a *= b) => "
);
result
=
(
a
*=
b
);
console
.
log
(
result
);
console
.
log
(
"Value of a => (a /= b) => "
);
result
=
(
a
/=
b
);
console
.
log
(
result
);
console
.
log
(
"Value of a => (a %= b) => "
);
result
=
(
a
%=
b
);
console
.
log
(
result
);
Experiments/experiments07/Tutorial/bitwiseOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
2
;
// Bit presentation 10
var
b
=
3
;
// Bit presentation 11
console
.
log
(
"(a & b) => "
);
result
=
(
a
&
b
);
console
.
log
(
result
);
console
.
log
(
"(a | b) => "
);
result
=
(
a
|
b
);
console
.
log
(
result
);
console
.
log
(
"(a ^ b) => "
);
result
=
(
a
^
b
);
console
.
log
(
result
);
console
.
log
(
"(~b) => "
);
result
=
(
~
b
);
console
.
log
(
result
);
console
.
log
(
"(a << b) => "
);
result
=
(
a
<<
b
);
console
.
log
(
result
);
console
.
log
(
"(a >> b) => "
);
result
=
(
a
>>
b
);
console
.
log
(
result
);
Experiments/experiments07/Tutorial/comparisonOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
10
;
var
b
=
20
;
console
.
log
(
"(a == b) => "
);
result
=
(
a
==
b
);
console
.
log
(
result
);
console
.
log
(
"(a < b) => "
);
result
=
(
a
<
b
);
console
.
log
(
result
);
console
.
log
(
"(a > b) => "
);
result
=
(
a
>
b
);
console
.
log
(
result
);
console
.
log
(
"(a != b) => "
);
result
=
(
a
!=
b
);
console
.
log
(
result
);
console
.
log
(
"(a >= b) => "
);
result
=
(
a
>=
b
);
console
.
log
(
result
);
console
.
log
(
"(a <= b) => "
);
result
=
(
a
<=
b
);
console
.
log
(
result
);
Experiments/experiments07/Tutorial/conditionalOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
10
;
var
b
=
20
;
var
linebreak
=
"<br />"
;
console
.
log
(
"((a > b) ? 100 : 200) => "
);
result
=
(
a
>
b
)
?
100
:
200
;
console
.
log
(
result
);
console
.
log
(
"((a < b) ? 100 : 200) => "
);
result
=
(
a
<
b
)
?
100
:
200
;
console
.
log
(
result
);
Experiments/experiments07/Tutorial/event01/app.js
0 → 100644
View file @
7b066cf
var
events
=
require
(
'events'
);
var
eventEmitter
=
new
events
.
EventEmitter
();
var
connectHandler
=
function
connected
()
{
console
.
log
(
'connection successful.'
);
eventEmitter
.
emit
(
'data_received'
);
}
eventEmitter
.
on
(
'connection'
,
connectHandler
);
eventEmitter
.
on
(
'data_received'
,
function
(){
console
.
log
(
'data received successfully.'
);
});
eventEmitter
.
emit
(
'connection'
);
console
.
log
(
"Program Ended."
);
Experiments/experiments07/Tutorial/event02/app.js
0 → 100644
View file @
7b066cf
var
events
=
require
(
'events'
);
var
eventEmitter
=
new
events
.
EventEmitter
();
var
listner1
=
function
listner1
()
{
console
.
log
(
'listner1 executed.'
);
}
var
listner2
=
function
listner2
()
{
console
.
log
(
'listner2 executed.'
);
}
eventEmitter
.
addListener
(
'connection'
,
listner1
);
eventEmitter
.
on
(
'connection'
,
listner2
);
var
eventListeners
=
require
(
'events'
).
EventEmitter
.
listenerCount
(
eventEmitter
,
'connection'
);
console
.
log
(
eventListeners
+
" Listner(s) listening to connection event"
);
eventEmitter
.
emit
(
'connection'
);
eventEmitter
.
removeListener
(
'connection'
,
listner1
);
console
.
log
(
"Listner1 will not listen now."
);
eventEmitter
.
emit
(
'connection'
);
eventListeners
=
require
(
'events'
).
EventEmitter
.
listenerCount
(
eventEmitter
,
'connection'
);
console
.
log
(
eventListeners
+
" Listner(s) listening to connection event"
);
console
.
log
(
"Program Ended."
);
Experiments/experiments07/Tutorial/forStatement.js
deleted
100755 → 0
View file @
1045e50
var
numbers
=
new
Array
(
1
,
2
,
2
,
3
,
4
)
for
(
var
num
in
numbers
)
{
// key and Value
console
.
log
(
num
+
" = "
+
numbers
[
num
]);;
}
console
.
log
(
"Exiting from the loop!"
);
Experiments/experiments07/Tutorial/ifelseStatement.js
deleted
100755 → 0
View file @
1045e50
var
age
=
20
;
if
(
age
>
18
)
{
console
.
log
(
"Qualifies for driving"
);
}
var
age
=
15
;
if
(
age
>
18
)
{
console
.
log
(
"Qualifies for driving"
);
}
else
{
console
.
log
(
"Does not qualify for driving"
);
}
var
book
=
"maths"
;
if
(
book
==
"history"
)
{
console
.
log
(
"History Book"
);
}
else
if
(
book
==
"maths"
)
{
console
.
log
(
"Maths Book"
);
}
else
if
(
book
==
"economics"
)
{
console
.
log
(
"Economics Book"
);
}
else
{
console
.
log
(
"Unknown Book"
);
}
Experiments/experiments07/Tutorial/logicalOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
true
;
var
b
=
false
;
console
.
log
(
"(a && b) => "
);
result
=
(
a
&&
b
);
console
.
log
(
result
);
console
.
log
(
"(a || b) => "
);
result
=
(
a
||
b
);
console
.
log
(
result
);
console
.
log
(
"!(a && b) => "
);
result
=
(
!
(
a
&&
b
));
console
.
log
(
result
);
Experiments/experiments07/Tutorial/mymodule/app.js
0 → 100644
View file @
7b066cf
var
dt
=
require
(
'./mymodule'
);
console
.
log
(
dt
.
myDateTime
());
Experiments/experiments07/Tutorial/mymodule/mymodule.js
0 → 100644
View file @
7b066cf
exports
.
myDateTime
=
function
()
{
return
Date
();
};
Experiments/experiments07/Tutorial/switchStatement.js
deleted
100755 → 0
View file @
1045e50
var
grade
=
'A'
;
console
.
log
(
"Entering switch block"
);
switch
(
grade
)
{
case
'A'
:
console
.
log
(
"Good job"
);
break
;
case
'B'
:
console
.
log
(
"Pretty good"
);
break
;
case
'C'
:
console
.
log
(
"Passed"
);
break
;
case
'D'
:
console
.
log
(
"Not so good"
);
break
;
case
'F'
:
console
.
log
(
"Failed"
);
break
;
default
:
console
.
log
(
"Unknown grade"
)
}
console
.
log
(
"Exiting switch block"
);
switch
(
grade
)
{
case
'A'
:
console
.
log
(
"Good job"
);
case
'B'
:
console
.
log
(
"Pretty good"
);
case
'C'
:
console
.
log
(
"Passed"
);
case
'D'
:
console
.
log
(
"Not so good"
);
case
'F'
:
console
.
log
(
"Failed"
);
default
:
console
.
log
(
"Unknown grade"
);
}
console
.
log
(
"Exiting switch block"
);
Experiments/experiments07/Tutorial/typeofOperator.js
deleted
100755 → 0
View file @
1045e50
var
a
=
10
;
var
b
=
"String"
;
result
=
(
typeof
b
==
"string"
?
"B is String"
:
"B is Numeric"
);
console
.
log
(
"Result => "
);
console
.
log
(
result
);
result
=
(
typeof
a
==
"string"
?
"A is String"
:
"A is Numeric"
);
console
.
log
(
"Result => "
);
console
.
log
(
result
);
Experiments/experiments07/Tutorial/variables.js
deleted
100755 → 0
View file @
1045e50
var
name
=
"Ali"
;
var
money
;
money
=
2000
;
console
.
log
(
"my name is "
+
name
);
console
.
log
(
"my money is "
+
money
);
var
myVar
=
"global"
;
// Declare a global variable
function
checkscope
(
)
{
var
myVar
=
"local"
;
// Declare a local variable
console
.
log
(
"print myVar "
+
myVar
);
}
console
.
log
(
"print myVar "
+
myVar
);
checkscope
();
Experiments/experiments07/Tutorial/whileStatement.js
deleted
100755 → 0
View file @
1045e50
var
count
=
0
;
console
.
log
(
"Starting Loop "
);
while
(
count
<
10
)
{
console
.
log
(
"Current Count : "
+
count
);
count
++
;
}
console
.
log
(
"Loop stopped!"
);
var
count
=
0
;
console
.
log
(
"Starting Loop"
);
do
{
console
.
log
(
"Current Count : "
+
count
);
count
++
;
}
while
(
count
<
5
);
console
.
log
(
"Loop stopped!"
);
Experiments/experiments07/assignment01/assignment01.js
deleted
100755 → 0
View file @
1045e50
function
addPrice
(
amount
)
{
this
.
price
=
amount
;
}
function
book
(
title
,
author
)
{
this
.
title
=
title
;
this
.
author
=
author
;
this
.
addPrice
=
addPrice
;
}
var
bookList
=
new
Array
(
new
book
(
"Perl1"
,
"Mohtashim"
),
new
book
(
"Smith"
,
"Mohtashim"
),
new
book
(
"Carl"
,
"Mohtashim"
),
new
book
(
"Perl2"
,
"Mohtashim"
));
console
.
log
(
bookList
);
console
.
log
(
"After Sorting"
);
bookList
.
sort
(
sortBook
);
// sortBook 이라는 comparing function을 완성하시오.
// sortBook(a, b) { if (a > b) return 1; else if (a < b) return -1; else return 0;
// 1 순위 : title
// 2 순위 : author
console
.
log
(
bookList
);
Experiments/experiments07/assignment02/assignment02.js
deleted
100755 → 0
View file @
1045e50
function
slice
(
str
,
start
,
end
)
{
}
var
str
=
"Apples are round, and apples are juicy."
;
var
sliced
=
str
.
slice
(
1
,
3
);
// String.slice method와 동일하게 동작하는 slice function을 구현하시오.
// 아래의 console.log 2개의 출력이 동일해야 함
console
.
log
(
sliced
);
console
.
log
(
slice
(
str
,
1
,
3
));
Experiments/experiments07/assignment03/assignment03.js
deleted
100755 → 0
View file @
1045e50
function
reverse
(
input
)
{
}
var
arr
=
[
0
,
1
,
2
,
3
];
// Array.reverse Method와 동일하게 동작하는 reverse function을 구현하시오.
// 아래의 console.log 2개의 출력이 동일해야 함
console
.
log
(
"Reversed array is : "
+
arr
.
reverse
()
);
arr
.
reverse
();
console
.
log
(
"Reversed array is : "
+
reverse
(
arr
));
Experiments/experiments07/debugging/debugging.js
deleted
100755 → 0
View file @
1045e50
var
test
=
new
Array
(
1
,
2
,
3
,
4
,
5
,
6
);
for
(
var
aa
in
test
)
{
console
.
log
(
aa
);
}
Please
register
or
login
to post a comment