try{
정상적으로 처리되어야할 코드
런타임에서 에러가 발생하여 에외가 발생하거나,
throw 문을 통해 예외를 직접 발생시킬수 있다.

}catch(e){
예외 발생시 실행될 코드
  예외와 관련된 정보를  e 변수를 통해 참조
  예외를 처리 or 무시할수 있고, 
  throw문을 통해 예외를 다시 발생시킬수 있습니다. 
}finally{
try, catch 실행 완료후 무조건 실행이 필요한 코드
}


var x = 5;
var result;

try{
    result = x * y;
    document.writeln(result);
} catch(e){
    document.writeln(e);
}finally{
    document.writeln('ok');
}
/*
result : 
ReferenceError: y is not defined 
ok 
*/

try{
    result = x / 0;
    document.writeln(result);
    throw new Error('0으로 나눌 수 없습니다.');
} catch(e){
    document.writeln(e);
    document.writeln('
'); }finally{ document.writeln('ok'); document.writeln('
'); } /* result : 5 Error: 0으로 나눌 수 없습니다. ok */ try{ var calculator; calculator = calculator || {add : function(op1, op2){ return op1 + op2; }}; calculator && document.write(calculator.add(2,3)); calculator && document.write(calculator.sub(2,3)); }catch(e){ document.write(e); } /* result : 5 TypeError: calculator.subtract is not a function */


Posted by 달팽이맛나
,

[JavaScript] for...in

JavaScript 2014. 1. 10. 17:45


for...in 문은 객체의 프로퍼티나 배열의 원소에 대해 순서대로 반복처리를 실행


변수에는 객체로부터 나온 프로퍼티명이 저장되거나, 배열로부터 나온 인덱스번호가 저장된다.


for( 변수 in "객체" or "배열"){


}

var arr = [ {name: '정도전', age: 50}, {name: '이성계', age: 60}, {name: '정몽주', age: 54}, {name: '이방원', age: 43} ]; for(var idx in arr){ for(var prop in arr[idx]){ document.writeln(prop + ' : ' + arr[idx][prop]); if(prop == 'age'){ break; } } }


Posted by 달팽이맛나
,

[aptana] 설정

Web Dev 2014. 1. 10. 17:28



확장자 추가

Perferences > General > Content Types > Add



테마 변경

Perferences > Aptana Studio> Theme > 변경



jQuery 자동완성 쓰기

메뉴 > Commands > Bundle developer > install bundle > jquery 선택



폰트

Verdana 

Posted by 달팽이맛나
,

첫번째 값을 평가한후 뒤에 값을 평가하지 않는것.


//논리 연산자

/*
var aa = false;
var bb = true;

aa && bb // bb 평가x
aa || bb // bb 평가
*/


var calculator;

// &&연산에서 좌측 표현식이 undefined값을 가지면 
//false로 평가되어 우측 평가식을 실행하지 않는다.
calculator && document.writeln("calcuator.add(2,3):" + calculator.add(2,3));

calculator = {
	add : function(op1, op2){
		return op1 + op2;
	}
};

// && 연산에서 좌측 표현식이 0, undefined, null, NaN, "" 이외의 값을 가지면 
// true로 평가되어 우측평가식이 실행됩니다.
calculator && document.writeln("calcuator.add(2,3):" + calculator.add(2,3));

// || 연산에서 좌측 표현식이 undefined값을 가지면 false로 평가되어 우측 평가식을 실행함.
calculator.subtract || (calculator.subtract = function(op1, op2){ return op1 - op2; });
calculator.subtract || document.writeln("calcuator.subtract (2,3):" + calculator.subtract (2,3));

		


Posted by 달팽이맛나
,

undefined 

- 변수가 선언은 되었지만 값이 할당된 적이 없는 변수에 접근하건, 존재하지 않은 객체 프로퍼티에 접근할 경우 반환되는 값.

- 논리 연산에서 false로, 

  산술연산에서는 NaN로, 

  문자열 연산에서는 "undefined"로 변환되어 연산됨.



null

- 예약어

- 보통 참조 타입과 함께 쓰여, 어떠한 객체도 나타내지 않는 특수한 값으로 사용

- 논리 연산에서는 false로, 

   산술연산에서는 0으로, 

   문자열 연산에서는 "null"로 변환되어 연산됨.

		
//undefined와 null
var a;
var obj = {};
		
document.writeln('a: '+ a);//a: undefinde
document.writeln('obj: '+ obj);//obj: [object Object]
document.writeln('obj.prop: '+ a);//a: obj.prop:: undefined
		
obj = null; //객체 참조를 제거
document.writeln("obj: " + obj);//obj : null
		
if(!a){} //!undefined
if(!obj){} //!null


Posted by 달팽이맛나
,


리터럴(Literal) : 프로그램의 코드상에 데이터의 값을 표현하는 방식


자바스크립트의 리터럴 :

 - 숫자 리터럴, 문자열 리터럴, 배열 리터럴, 객체 리터럴, 함수 리터럴, 블리언 리터럴, undefined와 null 리터럴



Posted by 달팽이맛나
,

[Java] interface

JAVA 2014. 1. 9. 15:17

 

interface

- abstract 클래스의 한 종류로 포함 멤버의 제약을 가짐(순수 디자인 목적)

- 다중 상속이 가능한 유일한 클래스

 

interface의 포함 멤버

 - public static final 멤버 필드

 - public abstract 멤버 메서드

 - public static inner 클래스

interface AAA{
	//모두 동일
	public static int a = 0;
	public static final int b = 100;
	public final int c = 200;
	public int d = 300;

	public abstract void aaa();
	public void bbb();
	void ccc();
}

interface E{}
interface F extends E{}
interface G{}
interface H extends E, G{}

class I{}
class J implements E, G{}
class K extends I implements E, G{}

Posted by 달팽이맛나
,

[Java] abstract

JAVA 2014. 1. 9. 15:17

 

abstract 메서드

 - 메서드의 내용부가 정의 되지 않은 형태로 모델 개념의 메서드

 - 반드시 오버라이딩 되어야 사용 가능

 

abstract class AA{     public abstract void aaa(); }

 

 

abstract 클래스

abstract 클래스

 - abstract 메서드를 포함하고 있는 클래스로 다형성 표현으로 사용

 - 객체를 발생시킬 수 없는 것을 제외하면 일반 클래스와 동일

function helloSyntaxHighlighter()
{
	return "hi!";
}
Posted by 달팽이맛나
,