"함수 str repeat()"의 두 판 사이의 차이

8번째 줄: 8번째 줄:
console.log( "hello".repeat(3) );
console.log( "hello".repeat(3) );
// hellohellohello
// hellohellohello
</source>
==Perl==
[[분류: Perl]]
<source lang='Perl'>
print "hello" x 3
# hellohellohello
</source>
</source>



2018년 8월 1일 (수) 14:34 판


str_repeat

1 JavaScript

String.prototype.repeat=function(n){return new Array(n+1).join(this)}
console.log( "hello".repeat(3) );
// hellohellohello

2 Perl

print "hello" x 3
# hellohellohello

3 PHP

echo str_repeat("hello", 3);
// hellohellohello

4 Python

print "hello" * 3
# hellohellohello

5 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}